<include file='Admin/Tpl/Public/nav.html' />
<link href="http://libs.useso.com/js/jqueryui/1.10.0/css/smoothness/jquery-ui-1.10.0.custom.min.css" media="all" rel="alternate stylesheet" title="gray-theme" type="text/css" />
<style type="text/css">
.ui-dialog .ui-state-error { padding: .3em; }
.ui-dialog{ z-index:3000;}
.ui-dialog .ui-widget-header{background-color:#489be7; color:#fff; padding:6px; height:40px}
.ui-dialog .ui-dialog-titlebar-close{float:right; border:1px solid black}
.ui-dialog-buttonset{text-align:right;}
.ui-dialog-buttonset button{ margin-right:10px;}
.ui-tooltip{ position:absolute; display:none !important}

</style>
<div class="page-content">
    <div class="container-fluid">
    	<br/>
        
        <div class="col-sm-3 left">
            <div class="the-box">
                <div class="table-responsive div1 div_search">
                    <h4>添加会议</h4>
                    <form method="post" action="__URL__/add_meeting" enctype="multipart/form-data">
                        <div class="form-group">
                            <label>会议标题 <span style="color:red">*</span></label>
                            <div>
                                <input type="text" class="form-control must" type="text" name="meeting_title" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label>开始日期 <span style="color:red">*</span></label>
                            <div>
                                <input type="text" class="form-control" data-data-format="yyyy-mm-dd" type="text" name="meeting_date" placeholder="2015-01-22" value="<php>echo date('Y-m-d')</php>" />
                            </div>
                        </div>
                        <div class="form-group">
                        	<label>开始时间</label>
                            <div class="input-group input-append bootstrap-timepicker">
                                <input type="text" class="form-control timepicker" name="meeting_startTime">
                                <span class="input-group-addon add-on"><i class="fa fa-clock-o"></i></span>
                            </div>
                        </div>
                        <div class="form-group">
                        	<label>结束时间</label>
                            <div class="input-group input-append bootstrap-timepicker">
                                <input type="text" class="form-control timepicker" name="meeting_endTime">
                                <span class="input-group-addon add-on"><i class="fa fa-clock-o"></i></span>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label>会议地点 <span style="color:red">*</span></label>
                            <div>										
                                <input class="form-control must" type="text" name="meeting_local" />
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label>会议分类</label>
                            <div>										
                                <select class="form-control" tabindex="2" name="meeting_type">
                                    <option value="0">普通会议</option>
                                    <option value="1">周会</option>
                                    <option value="2">月会</option>													
                                </select>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label>会议分组</label>
                            <div>										
                                <select class="form-control" tabindex="2" name="meeting_category">
                                    <foreach name="meeting_category" item="value">
                                        <option value="{$value.category_id}">{$value.category_name}</option>
                                    </foreach>													
                                </select>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label> 添加参会人 <span style="color:red">*</span></label>
                            <br/>
                            <div class="radio-inline" onclick="_choose_meeting_join(1)">
                              <label>
                                <input type="radio" value="1" name="meeting_join_type" checked>
                                全体
                              </label>
                            </div>
                            <div class="radio-inline" onclick="_choose_meeting_join(2)">
                              <label>
                                <input type="radio" value="2" name="meeting_join_type">
                                选择参会人
                              </label>
                            </div>
                        </div>
                        
                        <div class="form-group" id="meeting_join" style="display:none">
                            <label>参会人</label>
                            <div>										
                                <input  class="form-control" type="text" name="meeting_join" />
                            </div>
                        </div>
                        
                        <div class="form-group" id="meeting_secret" style="display:none">
                            <label>密送</label>
                            <div>										
                                <input  class="form-control" type="text" name="meeting_join_secret" />
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label>消息附言</label>
                            <div>										
                                <input  class="form-control" type="text" name="meeting_description" />
                            </div>
                        </div>
                        
                        <div class="form-group">
                             <input class="btn btn-primary" id="submit"  type="submit" value="添加" />
                        </div>
                    </form>
                </div>
                <div class="table-responsive" id="hl"></div>
			</div>
        </div>
        
        <div class="col-sm-9 right">
            <div class="the-box">
                <div id="div_box" style="float:right">
                    <!--会议室搜索<-->
                    <span>搜索：</span>
                    <div class="btn-group">
                        <button type="button" class="btn btn-default city_check" name="1">会议类型选择</button>
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <volist name='meeting_category' id='value'>
                                <li><a class="city room_check" name="{$value.category_id}">{$value.category_name}</a></li>
                            </volist>
                        </ul>
                    </div>
                </div>
                <div class="table-responsive div1 div_search">
                    <table class="table table-th-block table-hover">
                        <thead>
                        <tr style="text-align:center">
                        	<td style="text-align:center;width:60px">会议编号</td>
                            <td style="text-align:center;width:180px">会议开始时间</td>
                            <td style="text-align:center">会议名称</td>
                            <td style="text-align:center;width:120px">会议类型</td>
                            <td style="text-align:center;width:80px">操作</td>
                          </tr>
                        </thead>
                        <tbody>
                            <volist name="rs.data" id="val"> 
                              <tr>                                      
                              	<td style='text-align:center;vertical-align:middle'>{$val.meeting_id}</td>
                                <td style='text-align:center;vertical-align:middle'>{$val.meeting_startTime}</td>
                                <td style='text-align:center;vertical-align:middle'>{$val.meeting_title}</td>
                                <td style='text-align:center;vertical-align:middle'>{$val.meeting_category}</td>
                                <td style='text-align:center;vertical-align:middle'>
                                   <!-- <a href='javascript:void(0)' onclick="to_upt({$val.meeting_id})" title='Edit'>修改</a>&nbsp;|&nbsp;
                                   --> <a href='javascript:void(0)' name="{$val.meeting_title}" onclick='to_del({$val.meeting_id})' title='Delete'>删除</a>
                                </td>
                              </tr>
                            </volist>
                        </tbody>
                    </table>
                    <ul class="pagination success">{$rs.show}</ul>
                </div>
                <div class="table-responsive" id="hl"></div>
			</div>
        </div>
    </div>
</div>
</div>

<div id="dialog-form2" title="选择参会人" style="background:#fff;overflow:auto !important; border:1px solid #489be7 !important">
  <form>
    <!-- <fieldset> -->
    	<php>foreach($rs['audience_list'] as $key=>$val){</php>
            <div class="form-group" style="margin-top:30px">
                <div class="col-md-2">
                    <label class="checkbox">
                        <input type="checkbox" name="choose_all" data-key="<php>echo $key</php>" value="1" /><span><php>echo $key</php></span>
                    </label>
                </div>
            </div>
            <div class="clear"></div>
            <div class="form-group">
                <div class="col-md-12 left">
                    <php>foreach($val as $val1){</php>
                        <label class="checkbox-inline">
                            <input type="checkbox" name="choose_audience" data-key="<php>echo $key</php>" value="{$val1.audience_id}"><span>{$val1.audience_name}</span>
                        </label>
                    <php>}</php>
                </div>
            </div>
            <div class="clear"></div>
            <hr />
        <php>}</php>
      <input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
    <!-- </fieldset> -->
  </form>
</div>

<div id="dialog-form3" title="选择密送人" style="background:#fff;overflow:auto !important; border:1px solid #489be7 !important">
  <form>
    <fieldset>
    	<php>foreach($rs['audience_list'] as $key=>$val){</php>
            <div class="form-group" style="margin-top:30px">
                <div class="col-md-2">
                    <label class="checkbox">
                        <input type="checkbox" name="choose_all_secret" data-key="<php>echo $key</php>" value="1" /><span><php>echo $key</php></span>
                    </label>
                </div>
            </div>
            <div class="clear"></div>
            <div class="form-group">
                <div class="col-md-12 left">
                    <php>foreach($val as $val1){</php>
                        <label class="checkbox-inline">
                            <input type="checkbox" name="choose_audience_secret" data-key="<php>echo $key</php>" value="{$val1.audience_id}"><span>{$val1.audience_name}</span>
                        </label>
                    <php>}</php>
                </div>
            </div>
            <div class="clear"></div>
            <hr />
        <php>}</php>
      <input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
    </fieldset>
  </form>
</div>
</body>
</html>
<script src="http://libs.useso.com/js/jqueryui/1.10.3/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
//-------------------------------choose_audience_meeting_join----------------------------------
var dialog2 = $( "#dialog-form2" ).dialog({
	autoOpen: false,
	height: 500,
	width: 960,
	zIndex:3001,
	close:choose_this_audience
});
var dialog3 = $( "#dialog-form3" ).dialog({
	autoOpen: false,
	height: 500,
	width: 960,
	zIndex:3002,
	close:choose_this_audience_secret
});

$("input[name=meeting_join]").click(function(){
		dialog2.dialog( "open" );
});
$("input[name=meeting_join_secret]").click(function(){
		dialog3.dialog( "open" );
});

function choose_this_audience(){
	var str = '';
	$('input[name="choose_audience"]:checked').each(function(index, element) {
	   str +=","+$(this).val();
	});
	$('input[name="meeting_join"]').val(str.substring(1));
}

function choose_this_audience_secret(){
	var str = '';
	$('input[name="choose_audience_secret"]:checked').each(function(index, element) {
	   str +=","+$(this).val();
	});
	$('input[name="meeting_join_secret"]').val(str.substring(1));	
}

var selfval = '';
$("input[name='choose_all']").each(function(index, element) {
	$(this).bind('click',function(){
		selfval = $(this).attr('data-key');
		if(this.checked){
			$("input[name='choose_audience']").each(function(index, element) {
			   if($(this).attr('data-key') == selfval)
					$(this).attr('checked',true);
			});
		}else{
			$("input[name='choose_audience']").each(function(index, element) {
			   if($(this).attr('data-key') == selfval)
					$(this).attr('checked',false);
			});
		}
	});
});
//----------------------------------secret start-------------------------------------------
var selfval1 = '';
$("input[name='choose_all_secret']").each(function(index, element) {
	$(this).bind('click',function(){
		selfval1 = $(this).attr('data-key');
		if(this.checked){
			$("input[name='choose_audience_secret']").each(function(index, element) {
			   if($(this).attr('data-key') == selfval1)
					$(this).attr('checked',true);
			});
		}else{
			$("input[name='choose_audience_secret']").each(function(index, element) {
			   if($(this).attr('data-key') == selfval1)
					$(this).attr('checked',false);
			});
		}
	});
});

//-------------------------------choose_audience_meeting_join end-------------------------------


function _choose_meeting_join($a){
	if($a == 2){
		$('#meeting_join').css('display','');
		$('#meeting_secret').css('display','');
	}else{
		$('#meeting_join').css('display','none');
		$('#meeting_secret').css('display','none');
	}
}

function to_del($id){
	var $name = this.attr('name');
	if(confirm('确认删除?')){
		$.get(
			'__URL__/delete_meeting?meeting_id='+$id,
			function(data){
				if(data.state == 0){
					if(confirm('是否推送给相关参会人员?')){
						$.get(
							'__URL__/push_meeting_notice?meeting_id='+$id+'&action=delete&name='+$name,
							function(data1){
								if(data1.state == 0){
									alert('推送成功')	
								}else{
									alert('推送失败')	
								}
							},'json'
						)
					}
					window.location='__SELF__';
				}else
					alert('会议删除失败');
		},'json');
	}
}


$(".city").click(function(){
	var local_id =$(this).attr("name");
	var local_name = $(this).text();
	$(".city_check").attr({"name":local_id});
	$(".city_check").text(local_name);
	var param ={
		category_id:$(this).attr('name'),	
	}
	window.location = '__URL__/meeting_list?category_id='+local_id;
});

if('<php>echo $_GET["category_id"]</php>'!=''){
	$(".city").each(function(index, element) {
    	if($(this).attr('name')=='<php>echo $_GET["category_id"]</php>'){
			var local_id =$(this).attr("name");
			var local_name = $(this).text();
			$(".city_check").attr({"name":local_id});
			$(".city_check").text(local_name);	
		}
	});		
}
</script>
